package com.cirkana.viewer.security.model;

import java.util.ArrayList;

public class SecurityController {

	public static final String SERVICE_CIRKANA = "cirkana";
	public static final String SERVICE_TWITTER = "twitter";

	public static Profile createProfile(String user, String password) {
		Profile profile = new Profile();
		profile.setCirkanaCredential(createCredential(SERVICE_CIRKANA, user));
		return profile;
	}

	public static Profile addCredential(Profile profile, Credential credential) {
		if (profile.getCredentials() == null)
			profile.setCredentials(new ArrayList<Credential>());
		profile.getCredentials().add(credential);
		return profile;
	}
	
	public static Profile addCredential(Profile profile, String service,
			String user) {
		return addCredential(profile, createCredential(service, user));
	}

	protected static Credential createCredential(String service, String user) {
		Credential credential = new Credential();
		credential.setService(service);
		credential.setUser(user);
		return credential;
	}
	

}
